home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 February: Technology Seed / Mac Tech Seed Feb '97.toast / OpenDoc 1.2b2c1 / Implementation / Messaging / MssgSI.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1997-02-13  |  23.1 KB  |  699 lines  |  [TEXT/MPS ]

  1. /*
  2.     File:        MssgSI.cpp
  3.  
  4.     Contains:    Implementation of Mac specific DefaultAccessorSI class.
  5.  
  6.     Owned by:    Nick Pilch
  7.  
  8.     Copyright:    © 1994 - 1996 by Apple Computer, Inc., all rights reserved.
  9.  
  10.     Change History (most recent first):
  11.  
  12.          <5>      12/13/96    JP        1610152: Changed part from null to be part
  13.                                     from anything
  14.          <4>      10/15/96    JP        1244606, 1375124 : Improved Container &
  15.                                     added Active Part props.
  16.          <3>     9/26/96    JP        1372897: Fixed 'contains' operation.
  17.          <2>     9/23/96    JP        1384958: Removed SEPriv.h include
  18.         <38>     10/4/95    jpa        Added missing ODVolatiles [1285799]
  19.         <37>    25/09/95    NP        1979071: Check results of operator new.
  20.         <36>     9/11/95    NP        1272294: Messaging code cleanup. 1283174:
  21.                                     Mem leak plugs.
  22.         <35>      9/8/95    jpa        eeh: 1269501: Lowercase before string
  23.                                     comparisons.
  24.         <34>     8/23/95    NP        1276287: Move constant kODAppShell.
  25.         <33>     8/18/95    NP        1274946: Add kODErrCantCountFromLists.
  26.         <32>     8/16/95    eeh        1277001: remove ContainerRepresentsPart
  27.         <31>      8/7/95    NP        1275104: Exception safety.
  28.         <30>      8/3/95    RR        #1257260: Collapse B classes. Remove
  29.                                     somInit methods. Don't call IsInitialized
  30.                                     or SubclassResponsibility
  31.         <29>      8/1/95    eeh        1265319: accept NULL as representing part
  32.         <28>     7/27/95    eeh        1204615: call TrySwapToRootPart for 'exmn'
  33.         <27>     7/21/95    eeh        1266906: fix CallCountProc; 1262143: call
  34.                                     ODDisposeAppleEvent
  35.         <26>     6/30/95    JP        Release on dispose of standard part token
  36.         <25>     6/28/95    eeh        1262143: dispose AEDescs
  37.         <24>     6/27/95    NP        1263224: Remove Release call in
  38.                                     DiposeTokenProc for now.
  39.         <23>     6/26/95    NP        1262143: Dispose copy of Apple event made
  40.                                     in CallEventHandler
  41.         <22>     6/22/95    NP        1261984: Don't delete token after passing
  42.                                     it to ODNameResolver::DisposeToken!
  43.         <21>     6/20/95    NP        Removed dangerous comment.
  44.         <20>     6/19/95    eeh        1246443: add PartFrameFromStandardPartToken
  45.                                     etc.
  46.         <19>     6/13/95    eeh        1257105: fix string compare
  47.         <18>      6/7/95    eeh        1250399: implement default CompareProc
  48.         <17>     5/21/95    NP        1248898: GetUserToken, ODDescToAEDesc, etc.
  49.                                     recipe change.
  50.         <16>     5/18/95    eeh        1250061: implement countproc
  51.         <15>     4/28/95    eeh        1244258: IsValid->CheckValid; SOM_TRY
  52.                                     around it
  53.         <14>     4/27/95    NP        1244309-Default count proc returns -1 only
  54.                                     if the part is equal to kODAppShell.
  55.         <13>     4/27/95    eeh        1240648: call somSelf->IsValid
  56.         <12>     4/25/95    NP        1186795, 1237220, 1240571: Fixed whose
  57.                                     clauses by allowing swapping in count proc.
  58.         <11>     4/14/95    NP        1239651: Include SEPriv.h. 1238022: default
  59.                                     event handler was almost always returning
  60.                                     noErr.
  61.         <10>      4/7/95    eeh        1236842: call TrySwapToRootPart
  62.          <9>     3/24/95    eeh        1232249: remove frame from
  63.                                     DEFAULT_ACCESSOR_PARAMS
  64.          <8>     3/21/95    JP        1192027: Include ODRgstry & change some
  65.                                     constant names
  66.          <7>     3/13/95    NP        1226003: Remove GetContainingFrame from the
  67.                                     API. Use GetContextFromToken.
  68.          <6>      3/2/95    eeh        1214783: cleanup related to lists
  69.          <5>     2/22/95    eeh        1222901: look for StandardPartToken
  70.          <4>     2/21/95    eeh        1214783: add WildcardFromList accessor;
  71.                                     change accessor API
  72.          <3>      2/3/95    eeh        1217393: use new ODDesc etc
  73.          <2>     1/27/95    NP        1213948: New classes for ODDesc et al.
  74.          <1>     1/25/95    eeh        #1214783-first check-in as unique file.
  75.          <3>     1/11/95    NP        #1188520-Pass real ODPart to parts.
  76.          <2>      1/9/95    NP        1194880: MssgSI name changes.
  77.          <1>    11/15/94    NP        first checked in
  78.          <7>     9/23/94    NP        1188520-Pass the real ODPart descendent to
  79.                                     the SemanticInterface extension rather than
  80.                                     the ODPartWrapper.
  81.          <6>      9/9/94    NP        1185851: implement scripting. 1184040: API
  82.                                     changes.
  83.          <5>      9/9/94    jpa        Removed call to parent in Release, at
  84.                                     Nick's request. [1185656]
  85.          <4>      7/8/94    NP        Initialize fHelper field.
  86.          <3>      7/8/94    NP        Fixed bugs, implemented coercion handlers,
  87.                                     fixed initialization.
  88.          <2>      7/5/94    NP        Filled in CallEventHandler.
  89.          <1>      7/1/94    NP        first checked in
  90.  
  91.     To Do:
  92.     In Progress:
  93. */
  94.  
  95.  
  96. #ifndef _EXCEPT_
  97. #include "Except.h"
  98. #endif
  99.  
  100. #ifndef _DFLTACS_
  101. #include <DfltAcs.h>
  102. #endif
  103.  
  104. #ifndef _ODDESUTL_
  105. #include <ODDesUtl.h>
  106. #endif
  107.  
  108. #ifndef SOM_ODOSLToken_xh
  109. #include "ODOSLTkn.xh"
  110. #endif
  111.  
  112. #ifndef SOM_ODAppleEvent_xh
  113. #include "ODAplEvt.xh"
  114. #endif
  115.  
  116. #ifndef _ODREGISTRY_
  117. #include "ODRgstry.xh"
  118. #endif
  119.  
  120. #ifndef _SEUTILS_
  121. #include <SEUtils.h>
  122. #endif
  123.  
  124. #ifndef SOM_ODNameResolver_xh
  125. #include <NamRslvr.xh>
  126. #endif
  127.  
  128. #ifndef _PASCLSTR_
  129. #include <PasclStr.h>
  130. #endif
  131.  
  132. #define VARIABLE_MACROS
  133. #define DefaultAccessorSI_Class_Source
  134. #include <MssgSI.xih>
  135.  
  136. #ifndef SOM_Module_OpenDoc_StdDefs_defined
  137. #include <StdDefs.xh>
  138. #endif
  139.  
  140. #pragma segment DefaultAccessorSI
  141.  
  142. //------------------------------------------------------------------------------
  143. // function prototypes
  144. //------------------------------------------------------------------------------
  145.  
  146. static void ResolveDesc( Environment *ev, ODPart* part, ODSession* session,
  147.         ODOSLToken* obj, AEDesc* data );
  148.  
  149. //------------------------------------------------------------------------------
  150. // DefaultAccessorSI::InitCPlusSemanticInterface
  151. //------------------------------------------------------------------------------
  152.  
  153. SOM_Scope void  SOMLINK DefaultAccessorSIInitCPlusSemanticInterface(DefaultAccessorSI *somSelf, Environment *ev,
  154.         ODPart* base,
  155.         SIHelperAbs* helper,
  156.         ODSession* session)
  157. {
  158.     DefaultAccessorSIData *somThis = DefaultAccessorSIGetData(somSelf);
  159.     DefaultAccessorSIMethodDebug("DefaultAccessorSI","DefaultAccessorSIInitCPlusSemanticInterface");
  160.     
  161.     SOM_TRY
  162.         somSelf->InitSemanticInterface(ev, base, session);
  163.     SOM_CATCH_ALL
  164.     SOM_ENDTRY
  165. }
  166.  
  167. //------------------------------------------------------------------------------
  168. // DefaultAccessorSI::somUninit
  169. //------------------------------------------------------------------------------
  170.  
  171. SOM_Scope void  SOMLINK DefaultAccessorSIsomUninit(DefaultAccessorSI *somSelf)
  172. {
  173.     DefaultAccessorSIData *somThis = DefaultAccessorSIGetData(somSelf);
  174.     DefaultAccessorSIMethodDebug("DefaultAccessorSI","DefaultAccessorSIsomUninit");
  175.  
  176.     DefaultAccessorSI_parents_somUninit(somSelf);
  177. }
  178.  
  179. //------------------------------------------------------------------------------
  180. // DefaultAccessorSI::InitSemanticInterface
  181. //------------------------------------------------------------------------------
  182.  
  183. SOM_Scope void  SOMLINK DefaultAccessorSIInitSemanticInterface(DefaultAccessorSI *somSelf, Environment *ev,
  184.         ODPart* base,
  185.         ODSession* session)
  186. {
  187.     DefaultAccessorSIData *somThis = DefaultAccessorSIGetData(somSelf);
  188.     DefaultAccessorSIMethodDebug("DefaultAccessorSI","DefaultAccessorSIInitSemanticInterface");
  189.  
  190.     _fSession = session;
  191.  
  192.     DefaultAccessorSI_parent_ODSemanticInterface_InitSemanticInterface(somSelf, ev, base, session);
  193. }
  194.  
  195. //------------------------------------------------------------------------------
  196. // DefaultAccessorSI::GetSIHelper
  197. //------------------------------------------------------------------------------
  198.  
  199. SOM_Scope SIHelperAbs*  SOMLINK DefaultAccessorSIGetSIHelper(DefaultAccessorSI *somSelf, Environment *ev)
  200. {
  201.     DefaultAccessorSIData *somThis = DefaultAccessorSIGetData(somSelf);
  202.     DefaultAccessorSIMethodDebug("DefaultAccessorSI","DefaultAccessorSIGetSIHelper");
  203.  
  204.     return kODNULL;            // was _fHelper;
  205. }
  206.  
  207. //------------------------------------------------------------------------------
  208. // DefaultAccessorSI::CallEventHandler
  209. //------------------------------------------------------------------------------
  210.  
  211. SOM_Scope void  SOMLINK DefaultAccessorSICallEventHandler(DefaultAccessorSI *somSelf, Environment *ev,
  212.         ODPart* thePart,
  213.         ODAppleEvent* theODAppleEvent,
  214.         ODAppleEvent* reply)
  215. {
  216.     DefaultAccessorSIData *somThis = DefaultAccessorSIGetData(somSelf);
  217.     DefaultAccessorSIMethodDebug("DefaultAccessorSI","DefaultAccessorSICallEventHandler");
  218.  
  219.     OSErr error;            //= errAEEventNotHandled;
  220.  
  221.     SOM_TRY
  222.         somSelf->CheckValid(ev);
  223.  
  224.         AppleEvent realMessage;
  225.     
  226.         THROW_IF_ERROR( ODDescToAEDesc(theODAppleEvent, &realMessage) );
  227.  
  228.             AEEventClass eventClass = (AEEventClass)GetSLongAttr(
  229.                     &realMessage, keyEventClassAttr);
  230.             AEEventID eventID = (AEEventID)GetSLongAttr(
  231.                     &realMessage, keyEventIDAttr);
  232.     
  233.             EventHandlerProc ehp;
  234.     
  235.             if ( (eventClass == kAECoreSuite) && (eventID == kAEGetData) )
  236.                 ehp = HandleGetData;
  237.             else if ( (eventClass == kAECoreSuite) && (eventID == kAESetData) )
  238.                 ehp = HandleSetData;
  239.             else
  240.                 ehp = kODNULL;
  241.     
  242.             if ( ehp )
  243.                 error = (*ehp)( ev, thePart, theODAppleEvent, reply, _fSession );
  244.             else
  245.                 error = errAEEventNotHandled;
  246.  
  247.         ODDisposeAppleEvent(&realMessage);
  248.  
  249.         THROW_IF_ERROR( error );
  250.     SOM_CATCH_ALL
  251.     SOM_ENDTRY
  252. }
  253.  
  254. //------------------------------------------------------------------------------
  255. // DefaultAccessorSI::CallCoercionHandler
  256. //------------------------------------------------------------------------------
  257.  
  258. SOM_Scope void  SOMLINK DefaultAccessorSICallCoercionHandler(DefaultAccessorSI *somSelf, Environment *ev,
  259.         ODPart* thePart,
  260.         ODDesc* theODDesc,
  261.         ODDescType toType,
  262.         ODDesc* result)
  263. {
  264.     DefaultAccessorSIData *somThis = DefaultAccessorSIGetData(somSelf);
  265.     DefaultAccessorSIMethodDebug("DefaultAccessorSI","DefaultAccessorSICallCoercionHandler");
  266.  
  267.     OSErr error = errAECoercionFail;//= CallCoercionHandler(thePart, theODDesc, toType, result);
  268.     SOM_TRY
  269.         somSelf->CheckValid(ev);
  270.         WARN( "DefaultAccessorSICallCoercionHandler not implemented" );
  271.         THROW( error );
  272.     SOM_CATCH_ALL
  273.     SOM_ENDTRY
  274. }
  275.  
  276. //------------------------------------------------------------------------------
  277. // DefaultAccessorSI::CallObjectAccessor
  278. //------------------------------------------------------------------------------
  279.  
  280. SOM_Scope void  SOMLINK DefaultAccessorSICallObjectAccessor(DefaultAccessorSI *somSelf, Environment *ev,
  281.         ODPart* thePart,
  282.         ODDescType desiredClass,
  283.         ODOSLToken* container,
  284.         ODDescType containerClass,
  285.         ODDescType form,
  286.         ODDesc* selectionData,
  287.         ODOSLToken* value)
  288. {
  289.     DefaultAccessorSIData *somThis = DefaultAccessorSIGetData(somSelf);
  290.     DefaultAccessorSIMethodDebug("DefaultAccessorSI","DefaultAccessorSICallObjectAccessor");
  291.  
  292.     OSErr error;
  293.     SOM_TRY
  294.         somSelf->CheckValid(ev);
  295.  
  296.         ODDesc* userTokenWrapper = kODNULL;
  297.     
  298.         AEDesc realToken = NULL_DESCRIPTOR_DEFINITION;
  299.         DescType containerType = typeNull;
  300.         ODNameResolver* resolver = _fSession->GetNameResolver(ev);
  301.     
  302.         ASSERT(resolver->IsODToken( ev, container ), kODTrue);
  303.         userTokenWrapper = resolver->GetUserToken(ev, container);
  304.         THROW_IF_ERROR(ODDescToAEDesc(userTokenWrapper, &realToken ));
  305.         containerType = realToken.descriptorType;
  306.             
  307.         error = errAEAccessorNotFound;
  308.         PartAccessorProc pac;
  309.     
  310.         if ( (containerType == kODStandardPartTokenType) 
  311.                 || CanBeStandardPartToken( &realToken ) )
  312.             pac = GetWildcardFromPart;
  313.         else if ( containerType == typeAEList )
  314.             pac = GetWildcardFromList;
  315.         else if ( (desiredClass == cPart) /* && (containerType == typeNull)*/ )
  316.             pac = GetPartFromNULL;
  317.         else if ( (desiredClass == cProperty) && (containerType == typeNull) )
  318.             pac = GetPropFromNULL;
  319.         else if ( (desiredClass == cProperty) && (containerType == cProperty) )
  320.             pac = GetPropFromProp;
  321.         else if ( (thePart == kODAppShell) && ((containerType == typeNull)
  322.                 || (containerType == typeObjectBeingExamined)) )
  323.             pac = TrySwapToRootPart;
  324.         else
  325.             pac = kODNULL;
  326.     
  327.         if ( pac )
  328.         {
  329.             // We have to pass value as an ODOSLToken* in case the accessor
  330.             // needs to call CreateSwapToken on it.
  331.     
  332.             error = (*pac)( ev, thePart, desiredClass, &realToken,
  333.                     containerClass, form, selectionData, value,
  334.                     _fSession );
  335.         }
  336.         (void)AEDisposeDesc( &realToken );
  337.         THROW_IF_ERROR( error );
  338.  
  339.     SOM_CATCH_ALL
  340.     SOM_ENDTRY
  341. }
  342.  
  343. //------------------------------------------------------------------------------
  344. // DefaultAccessorSI::CallPredispatchProc
  345. //------------------------------------------------------------------------------
  346.  
  347. SOM_Scope void  SOMLINK DefaultAccessorSICallPredispatchProc(DefaultAccessorSI *somSelf, Environment *ev,
  348.         ODPart* thePart,
  349.         ODAppleEvent* theODAppleEvent,
  350.         ODAppleEvent* reply)
  351. {
  352.     DefaultAccessorSIData *somThis = DefaultAccessorSIGetData(somSelf);
  353.     DefaultAccessorSIMethodDebug("DefaultAccessorSI","DefaultAccessorSICallPredispatchProc");
  354.  
  355.     OSErr error = errAEEventNotHandled;//= CallPredispatchProc(thePart, theODAppleEvent, reply);
  356.     SOM_TRY
  357.         somSelf->CheckValid(ev);
  358.         WARN( "DefaultAccessorSICallPredispatchProc not implemented" );
  359.         THROW_IF_ERROR( error );
  360.     SOM_CATCH_ALL
  361.     SOM_ENDTRY
  362. }
  363.  
  364. //------------------------------------------------------------------------------
  365. // DefaultAccessorSI::CallCompareProc
  366. //------------------------------------------------------------------------------
  367.  
  368.  
  369. SOM_Scope void  SOMLINK DefaultAccessorSICallCompareProc(DefaultAccessorSI *somSelf, Environment *ev,
  370.         ODPart* thePart,
  371.         ODDescType oper,
  372.         ODOSLToken* obj1,
  373.         ODOSLToken* obj2,
  374.         ODBoolean* result)
  375. {
  376.     DefaultAccessorSIData *somThis = DefaultAccessorSIGetData(somSelf);
  377.     DefaultAccessorSIMethodDebug("DefaultAccessorSI","DefaultAccessorSICallCompareProc");
  378.  
  379.     OSErr error = errAEEventNotHandled;
  380.     AEDesc obj1AsData, obj2AsData, tmpDesc;
  381.  
  382.     SOM_TRY
  383.         somSelf->CheckValid(ev);
  384.  
  385.         obj1AsData.dataHandle = obj2AsData.dataHandle = tmpDesc.dataHandle =
  386.                 kODNULL;
  387.         ODNameResolver* resolver = _fSession->GetNameResolver(ev);
  388.         ResolveDesc( ev, thePart, _fSession, obj1, &obj1AsData );
  389.         ResolveDesc( ev, thePart, _fSession, obj2, &obj2AsData );
  390.         
  391.         // use CompareDescs in SEUtils
  392.         *result = CompareDescs(&obj1AsData, oper, &obj2AsData);
  393.  
  394.     SOM_CATCH_ALL
  395.         (void)AEDisposeDesc( &obj1AsData );
  396.         (void)AEDisposeDesc( &obj2AsData );
  397.         (void)AEDisposeDesc( &tmpDesc );
  398.     SOM_ENDTRY
  399. }
  400.  
  401. //------------------------------------------------------------------------------
  402. // DefaultAccessorSI::CallCountProc
  403. //------------------------------------------------------------------------------
  404.  
  405. SOM_Scope void  SOMLINK DefaultAccessorSICallCountProc(DefaultAccessorSI *somSelf, Environment *ev,
  406.         ODPart* thePart,
  407.         ODDescType desiredType,
  408.         ODDescType containerClass,
  409.         ODOSLToken* container,
  410.         ODSLong* result)
  411. {
  412.     DefaultAccessorSIData *somThis = DefaultAccessorSIGetData(somSelf);
  413.     DefaultAccessorSIMethodDebug("DefaultAccessorSI","DefaultAccessorSICallCountProc");
  414.  
  415.     // ASK TO SWAP TO SEE IF ROOT PART CAN HANDLE THIS. CallCountProc in
  416.     //    NamRslvr.cpp WILL SWAP TO THE ROOT PART IF kODCountProcSwapValue IS
  417.     //    RETURNED AND THE PART IS THE SHELL. THIS IS NOT THAT GREAT, SEEING AS
  418.     //    THE DEFAULT SEMANTIC INTERFACE SHOULD REALLY BE DETERMINING WHAT THE
  419.     //    PROPER PART TO SWAP TO IS.
  420.     SOM_TRY
  421.         somSelf->CheckValid(ev);
  422.         ODNameResolver* resolver = _fSession->GetNameResolver(ev);
  423.  
  424.         if ( thePart == kODAppShell)
  425.             *result = kODCountProcSwapValue;
  426.         else if ( resolver->IsODToken( ev, container ) )
  427.         {
  428.             ODError error = noErr;
  429.             ODDesc* tmpToken = resolver->GetUserToken(ev, container);
  430.             switch( tmpToken->GetDescType(ev) )
  431.             {
  432.                 case typeAEList:
  433.                     error = kODErrCantCountFromLists;
  434.                     break;
  435.                 case kODStandardPartTokenType:
  436.                 // (NULL token is not acceptable here)
  437.                 // <eeh> putting NULL back in because this breaks "every part
  438.                 // whose" when the root isn't scriptable.
  439.                 case typeNull:    
  440.                     // do the count;
  441.                     break;
  442.                 default:
  443.                 {
  444.                     AEDesc token;
  445.                     THROW_IF_ERROR( ODDescToAEDesc( tmpToken, &token ) );
  446.                     if ( !CanBeStandardPartToken( &token ) )
  447.                         error = errAEEventNotHandled;
  448.                     (void)AEDisposeDesc( &token );
  449.                 }
  450.             }
  451.             if ( error == noErr )
  452.             {
  453.                 if ( desiredType != cPart )
  454.                     *result = kODCountProcSwapValue;
  455.                 else
  456.                     *result = CountEmbeddedParts(ev, thePart);
  457.             }
  458.             else
  459.                 THROW( error );
  460.         }
  461.  
  462.     SOM_CATCH_ALL
  463.     SOM_ENDTRY
  464. }
  465.  
  466. //------------------------------------------------------------------------------
  467. // DefaultAccessorSI::CallDisposeTokenProc
  468. //------------------------------------------------------------------------------
  469.  
  470. SOM_Scope void  SOMLINK DefaultAccessorSICallDisposeTokenProc(DefaultAccessorSI *somSelf, Environment *ev,
  471.         ODPart* thePart,
  472.         ODOSLToken* unneededToken)
  473. {
  474.     DefaultAccessorSIData *somThis = DefaultAccessorSIGetData(somSelf);
  475.     DefaultAccessorSIMethodDebug("DefaultAccessorSI","DefaultAccessorSICallDisposeTokenProc");
  476.  
  477.     SOM_TRY
  478.         somSelf->CheckValid(ev);
  479.  
  480.         ODNameResolver* resolver = _fSession->GetNameResolver(ev);
  481.         if ( resolver->IsODToken( ev, unneededToken ) )
  482.         {
  483.             ODDesc* realTokenODDesc = resolver->GetUserToken( ev, unneededToken );
  484.             AEDesc realToken;
  485.             THROW_IF_ERROR(ODDescToAEDesc(realTokenODDesc, &realToken ));
  486.             DescType containerType = realToken.descriptorType;
  487.     
  488.             if ( containerType == typeAEList )
  489.             {
  490.                 long count;
  491.                 THROW_IF_ERROR( AECountItems( &realToken, &count ) );
  492.     
  493.                 for ( ODUShort index = 1; index <= count ; ++index )
  494.                 {
  495.                     AEDesc        oneToken;
  496.                     DescType    tokenDescType;
  497.                     THROW_IF_ERROR( AEGetNthDesc( &realToken, index, typeWildCard,
  498.                             &tokenDescType, &oneToken ) );
  499.                     ODOSLToken* subToken = new ODOSLToken();
  500.                     THROW_IF_NULL(subToken);
  501.                     subToken->InitODOSLToken(ev);
  502.                     THROW_IF_ERROR( AEDescToODDesc( &oneToken, subToken ) );
  503.                     (void)AEDisposeDesc( &oneToken );
  504.                     // <eeh> don't I need to call back into the resolver for this?
  505.                     // It could be someone else's token!
  506.                     TRY    
  507.                         resolver->DisposeToken( ev, subToken );
  508.                     //    somSelf->CallDisposeTokenProc( ev, thePart, subToken );
  509.                     CATCH_ALL
  510.                         // <eeh> just ignore errors here....I think.
  511.                     ENDTRY
  512.                 }
  513.             }
  514.             else if ( containerType == cPart )        // a standard part token
  515.             {
  516.                 ODPart*        part;
  517.                 ODFrame*    frame;
  518.                 
  519.                 PartFrameFromStandardPartToken( &realToken, &part, &frame );
  520.                 // BOTH THE PART AND FRAME DO NEED TO BE RELEASED HERE.
  521.                 ODReleaseObject( ev, part );
  522.                 ODReleaseObject( ev, frame );
  523.                 // leave error as errAEEventNotHandled so handle disposed
  524.             }
  525.     
  526.             // now dispose the *copy* we've made!  This isn't the token
  527.             // itself.  Hell, how *could* we dispose it?
  528.             (void)AEDisposeDesc( &realToken );
  529.         }
  530.  
  531.         // LET MESSAGING DISPOSE unneededToken itself.
  532.         THROW(errAEEventNotHandled);
  533.     SOM_CATCH_ALL
  534.     SOM_ENDTRY
  535. }
  536.  
  537. //------------------------------------------------------------------------------
  538. // DefaultAccessorSI::CallGetErrDescProc
  539. //------------------------------------------------------------------------------
  540.  
  541. SOM_Scope void  SOMLINK DefaultAccessorSICallGetErrDescProc(DefaultAccessorSI *somSelf, Environment *ev,
  542.         ODPart* thePart,
  543.         ODDesc** errDesc)
  544. {
  545.     DefaultAccessorSIData *somThis = DefaultAccessorSIGetData(somSelf);
  546.     DefaultAccessorSIMethodDebug("DefaultAccessorSI","DefaultAccessorSICallGetErrDescProc");
  547.  
  548.     OSErr error = errAEEventNotHandled;// = CallGetErrDescProc(thePart, errDesc);
  549.     SOM_TRY
  550.         somSelf->CheckValid(ev);
  551.         WARN( "DefaultAccessorSICallGetErrDescProc not implemented" );
  552.         THROW_IF_ERROR(error);
  553.     SOM_CATCH_ALL
  554.     SOM_ENDTRY
  555. }
  556.  
  557. //------------------------------------------------------------------------------
  558. // DefaultAccessorSI::CallGetMarkTokenProc
  559. //------------------------------------------------------------------------------
  560.  
  561. SOM_Scope void  SOMLINK DefaultAccessorSICallGetMarkTokenProc(DefaultAccessorSI *somSelf, Environment *ev,
  562.         ODPart* thePart,
  563.         ODOSLToken* dContainerToken,
  564.         ODDescType containerClass,
  565.         ODOSLToken* result)
  566. {
  567.     DefaultAccessorSIData *somThis = DefaultAccessorSIGetData(somSelf);
  568.     DefaultAccessorSIMethodDebug("DefaultAccessorSI","DefaultAccessorSICallGetMarkTokenProc");
  569.  
  570.     OSErr error = errAEEventNotHandled;// = CallGetMarkTokenProc(thePart, dContainerToken,
  571. //            containerClass, result);
  572.     SOM_TRY
  573.         somSelf->CheckValid(ev);
  574.         WARN( "DefaultAccessorSICallGetMarkTokenProc not implemented" );
  575.         THROW_IF_ERROR(error);
  576.     SOM_CATCH_ALL
  577.     SOM_ENDTRY
  578. }
  579.  
  580. //------------------------------------------------------------------------------
  581. // DefaultAccessorSI::CallMarkProc
  582. //------------------------------------------------------------------------------
  583.  
  584. SOM_Scope void  SOMLINK DefaultAccessorSICallMarkProc(DefaultAccessorSI *somSelf, Environment *ev,
  585.         ODPart* thePart,
  586.         ODOSLToken* dToken,
  587.         ODOSLToken* markToken,
  588.         ODSLong index)
  589. {
  590.     DefaultAccessorSIData *somThis = DefaultAccessorSIGetData(somSelf);
  591.     DefaultAccessorSIMethodDebug("DefaultAccessorSI","DefaultAccessorSICallMarkProc");
  592.  
  593.     OSErr error = errAEEventNotHandled;// = CallMarkProc(thePart, dToken, markToken, index);
  594.     SOM_TRY
  595.         somSelf->CheckValid(ev);
  596.         WARN( "DefaultAccessorSICallMarkProc not implemented" );
  597.         THROW_IF_ERROR(error);
  598.     SOM_CATCH_ALL
  599.     SOM_ENDTRY
  600. }
  601.  
  602. //------------------------------------------------------------------------------
  603. // DefaultAccessorSI::CallAdjustMarksProc
  604. //------------------------------------------------------------------------------
  605.  
  606. SOM_Scope void  SOMLINK DefaultAccessorSICallAdjustMarksProc(DefaultAccessorSI *somSelf, Environment *ev,
  607.         ODPart* thePart,
  608.         ODSLong newStart,
  609.         ODSLong newStop,
  610.         ODOSLToken* markToken)
  611. {
  612.     DefaultAccessorSIData *somThis = DefaultAccessorSIGetData(somSelf);
  613.     DefaultAccessorSIMethodDebug("DefaultAccessorSI","DefaultAccessorSICallAdjustMarksProc");
  614.  
  615.     OSErr error = errAEEventNotHandled;// = CallAdjustMarksProc(thePart, newStart, newStop, markToken);
  616.     SOM_TRY
  617.         somSelf->CheckValid(ev);
  618.         WARN( "DefaultAccessorSICallAdjustMarksProc not implemented" );
  619.         THROW_IF_ERROR(error);
  620.     SOM_CATCH_ALL
  621.     SOM_ENDTRY
  622. }
  623.  
  624. //------------------------------------------------------------------------------
  625. // Utility functions
  626. //------------------------------------------------------------------------------
  627.  
  628. static void ResolveDesc( Environment *ev, ODPart* part, ODSession* session,
  629.         ODOSLToken* obj, AEDesc* data )
  630. {
  631.     ODNameResolver* resolver = session->GetNameResolver(ev);
  632.  
  633.     if ( resolver->IsODToken( ev, obj ) )
  634.     {
  635.         AEDesc userToken, tmpDesc;
  636.         AERecord fakeReply, fakeAEVT;
  637.         userToken.dataHandle = tmpDesc.dataHandle = fakeReply.dataHandle =
  638.                 fakeAEVT.dataHandle = NULL;
  639.         ODAppleEvent* odreply, *odaevt;            ODVolatile(odaevt);
  640.         odreply = odaevt = kODNULL;                ODVolatile(odreply);
  641.  
  642.         TRY
  643.             ODDesc* userTokenHolder = resolver->GetUserToken( ev, obj );
  644.             THROW_IF_ERROR( ODDescToAEDesc( userTokenHolder, &userToken ) );
  645.             if ( userToken.descriptorType == cProperty )
  646.             {
  647.                 (void)AEDisposeDesc( &userToken );
  648.     
  649.                 THROW_IF_ERROR( ODDescToAEDesc( obj, &tmpDesc ) );
  650.                 THROW_IF_ERROR( AECreateList( NULL, 0, kODTrue, &fakeAEVT ) );
  651.                 THROW_IF_ERROR( AEPutParamDesc( &fakeAEVT, keyDirectObject,
  652.                         &tmpDesc ) );
  653.                 (void)AEDisposeDesc( &tmpDesc );
  654.                 odaevt = new ODAppleEvent();
  655.                 THROW_IF_NULL(odaevt);
  656.                 odaevt->InitODAppleEvent( ev );
  657.                 THROW_IF_ERROR( AEDescToODDesc( &fakeAEVT, odaevt ));
  658.                 (void)AEDisposeDesc( &fakeAEVT );
  659.         
  660.                 THROW_IF_ERROR( AECreateList( NULL, 0, kODTrue, &fakeReply ) );
  661.                 odreply = new ODAppleEvent();
  662.                 THROW_IF_NULL(odreply);
  663.                 odreply->InitODAppleEvent( ev );
  664.                 THROW_IF_ERROR( AEDescToODDesc( &fakeReply, odreply ));
  665.                 (void)AEDisposeDesc( &fakeReply );
  666.         
  667.                 THROW_IF_ERROR( HandleGetData( ev, part, odaevt, odreply,
  668.                         session ) );
  669.                 ODDeleteObject( odaevt );
  670.         
  671.                 THROW_IF_ERROR( ODDescToAEDesc( odreply, &fakeReply ));
  672.                 THROW_IF_ERROR( AEGetParamDesc( &fakeReply, keyDirectObject,
  673.                         typeWildCard, data ) );
  674.                 (void)AEDisposeDesc( &fakeReply );
  675.                 ODDeleteObject( odreply );
  676.             }
  677.             else
  678.             {
  679.                 *data = userToken;
  680.             }
  681.         CATCH_ALL
  682.             (void)AEDisposeDesc( &userToken );
  683.             (void)AEDisposeDesc( &tmpDesc );
  684.             (void)AEDisposeDesc( &fakeReply );
  685.             (void)AEDisposeDesc( &fakeAEVT );
  686.             ODDeleteObject( odaevt );
  687.             ODDeleteObject( odreply );
  688.             RERAISE;
  689.         ENDTRY
  690.     }
  691.     else
  692.     {
  693.         THROW_IF_ERROR( ODDescToAEDesc( obj, data ) );
  694.     }
  695. }
  696.  
  697.  
  698.  
  699.